package com.gxa.customer.controller;

import com.gxa.common.commons.R;
import com.gxa.common.params.AddHouseParam;
import com.gxa.common.params.QueryHouseParam;
import com.gxa.common.pojo.House;
import com.gxa.customer.redis.AccessLimit;
import com.gxa.customer.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/customer/house")
@AccessLimit(seconds = 1, maxCount = 3, apiName = "approvalRejected", timeUnit = TimeUnit.MINUTES)
public class HouseController {
    @Autowired
   private HouseService houseService;

    /**
     * 添加房产
     *
     * @return
     */
    @PostMapping(value = "/addHouse")
    public R addHouse(@RequestBody AddHouseParam param){
        System.out.println(param);
        return houseService.addHouse(param);
    }
    /**
     * 删除房产
     */
    @PostMapping("/delHouse")
    public R delHouse(@RequestBody List<Integer> ids){
        return houseService.delHouse(ids);
    }
    /**
     * 修改房产
     */
    @PostMapping("/updateHouse")
    public R updateHouse(@RequestBody House house){
        return houseService.updateHouse(house);
    }
    /**
     * 根据国家和所属项目选择房产
     */
    @PostMapping("/queryHouse")
    public R queryHouse(@RequestBody QueryHouseParam param){
        return houseService.queryHouse(param);
    }
}
